package your.rpg.namespace;

import java.util.ArrayList;

public class LevelData {
	
	private ArrayList<Level> levels;
	
	public LevelData(){
		levels = new ArrayList<Level>();
	}
	
	public void addLevel(int levelid, int imageid, String levelname,int level1, int level2, int level3, String point1, String point2, String point3){
		levels.add(new Level(levelid,imageid,levelname,level1,level2,level3,point1,point2,point3));
	}
	
	public void addEvent(int level, String listname, String action){
		for(int i = 0; i < levels.size(); i++)
		{
			if(levels.get(i).getLevelNumber() == level)
			{
				levels.get(i).addEvent(listname,action);
			}
		}
	}
	
	public boolean findLevel(int name){
		boolean found = false;
		for(int i = 0; i<levels.size();i++)
		{
			if(levels.get(i).getLevelNumber() == name)
			{
				found = true;
			}
		}
		return found;
	}
	
	public int getBackground(int name){
		int background = 0;
		for(int i = 0; i < levels.size(); i++)
		{
			if(levels.get(i).getLevelNumber() == name)
			{
				background = levels.get(i).getBackground();
			}
		}
		return background;
	}
	
	public int getObjectImage(int name,int index){
		int image = 0;
		for(int i = 0; i < levels.size(); i++)
		{
			if(levels.get(i).getLevelNumber() == name)
			{
				image = levels.get(i).getObjectImage(index);
			}
		}
		return image;
	}
	
	public int getObjectXpos(int name,int index){
		int xpos = 0;
		for(int i = 0; i < levels.size(); i++)
		{
			if(levels.get(i).getLevelNumber() == name)
			{
				xpos = levels.get(i).getObjectXpos(index);
			}
		}
		return xpos;
	}
	
	public int getObjectYpos(int name,int index){
		int ypos = 0;
		for(int i = 0; i < levels.size(); i++)
		{
			if(levels.get(i).getLevelNumber() == name)
			{
				ypos = levels.get(i).getObjectYpos(index);
			}
		}
		return ypos;
	}
	
	public int getObjectAmount(int name){
		int amount = 0;
		for(int i = 0; i < levels.size(); i++)
		{
			if(levels.get(i).getLevelNumber() == name)
			{
				amount = levels.get(i).getObjectAmount();
			}
		}
		return amount;	
	}
	
	public int getLevelAmount(){
		return levels.size();
	}
	
	public int getLevelNumber(int index){
		return levels.get(index).getLevelNumber();
	}
	
	public String getEvent(int name,String eventlist,int index){
		String event = "";
		for(int i = 0; i < levels.size(); i++)
		{
			if(levels.get(i).getLevelNumber() == name)
			{
				event = levels.get(i).getEvent(eventlist,index);
			}
		}
		return event;
	}

	public void setObjectPos(int currentlevel1, int index,int x, int y){
		for(int i = 0; i < levels.size(); i++)
		{
			if(levels.get(i).getLevelNumber() == currentlevel1)
			{
				levels.get(i).setObjectPos(index, x, y);
			}
		}
	}
	
	public void setObjectImage(int currentlevel1, int index,int imageid){
		for(int i = 0; i < levels.size(); i++)
		{
			if(levels.get(i).getLevelNumber() == currentlevel1)
			{
				levels.get(i).setObjectImage(index, imageid);
			}
		}
	}
	
	public void addObject(int currentlevel1, String naam,int imageid,int x,int y){
		for(int i = 0; i < levels.size(); i++)
		{
			if(levels.get(i).getLevelNumber() == currentlevel1)
			{
				levels.get(i).addObject(naam,imageid,x,y);
			}
		}
	}
	
	public void removeObject(int currentlevel1, int index){
		for(int i = 0; i < levels.size(); i++)
		{
			if(levels.get(i).getLevelNumber() == currentlevel1)
			{
				levels.get(i).removeObject(index);
			}
		}
	}
	
	public int getListSize(String list_name, int currentlevel1){
		int size = 0;
		for(int i = 0; i < levels.size(); i++)
		{
			if(levels.get(i).getLevelNumber() == currentlevel1)
			{
				size = levels.get(i).getListSize(list_name);
			}
		}
		return size;
	}
	
	public String getLevelName(int level){
		String level1 = "";
		for(int i = 0; i < levels.size(); i++)
		{
			if(levels.get(i).getLevelNumber() == level)
			{
				level1 = levels.get(i).getLevelName();
			}
		}
		return level1;
	}
	
	public int getEventNameId(int level, int number){
		int id = 0;
		for(int i = 0; i < levels.size(); i++)
		{
			if(levels.get(i).getLevelNumber() == level)
			{
				id = levels.get(i).getEventId(number);
			}
		}
		return id;
	}
	
	public String getEventPointNameId(int level, int number){
		String id = "";
		for(int i = 0; i < levels.size(); i++)
		{
			if(levels.get(i).getLevelNumber() == level)
			{
				id = levels.get(i).getEventPointId(number);
			}
		}
		return id;
	}
}
